<?php

/**
 * \file
 * Classe `RichTextArea`.
 */

namespace pilar\AdvancedFormMembers /* \cond */ ; /* \endcond */
{

// Utilisation de la librairie jwysiwyg
 global $pJS, $pCSS;
 $pJS[] = '/js/jwysiwyg-0.5/jquery.wysiwyg.js';
 $pCSS[] = '/js/jwysiwyg-0.5/jquery.wysiwyg.css';

/**
 * Membre RichTextArea
 *
 * \since 25/04/2009
 * \author Olivier LEMASLE <o.lemasle@gmail.com>
 *
 */
 
final class RichTextArea extends \pilar\SimpleFormMembers\TextArea {

protected function loadDefaultParams() {
 parent::loadDefaultParams();

 $this->params->define(array(
  'visibleControls' => array(),
  'hiddenControls' => array()
 ));
/* Available controls : bold, italic, strikeThrough, underline, justifyLeft, justifyCenter,
justifyRight, justifyFull, indent, outdent, subscript, superscript, undo, redo, insertOrderedList,
insertUnorderedList, insertHorizontalRule, createLink, insertImage, h1mozilla, h2mozilla, h3mozilla,
h1, h2, h3, cut, copy, paste, increaseFontSize, decreaseFontSize, html, removeFormat
*/
}

public function value($f = 'value') {
 return addslashes(parent::value($f));
}


protected function outputGuiController() {
 global $APPS;
 ?>
$('#<?php echo $this->globalId() ?>').wysiwyg({controls : {<?php
foreach( $this->get('visibleControls') as $control) {echo $control.' : {visible: true}, ';}
foreach( $this->get('hiddenControls') as $control) {echo $control.' : {visible: false}, ';}
?>
seperator00 : {visible: false}}});
$('#<?php echo $this->globalId() ?>').wysiwyg(
 'setContent','<?php echo str_replace("\r\n", '\n', stripcslashes($this->value())) ?>');
<?php if($this->status() == 'invalid') { ?>
 $('#<?php echo $this->globalId() ?>').addClass('invalid');
<?php } ?>
<?php
}

} // Class.

} // Namespace.
?>
